<script setup>
import { ref, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()

const selectedKeys = computed(() => {
  if (route.name === 'storage-config') {
    return ['2']
  }
  return ['1']
})

const handleMenuClick = ({ key }) => {
  switch (key) {
    case '1':
      router.push({ name: 'home' })
      break
    case '2':
      router.push({ name: 'storage-config' })
      break
    default:
      break
  }
}
</script>

<template>
  <div class="app-container">
    <!-- 顶部导航栏 -->
    <div class="app-header">
      <div class="header-content">
        <!-- Logo和标题区域 -->
        <div class="logo-section">
          <div class="logo-icon">
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
              <defs>
                <linearGradient id="logoGradient" x1="0%" y1="0%" x2="100%" y2="100%">
                  <stop offset="0%" style="stop-color:#83BBDC;stop-opacity:1" />
                  <stop offset="100%" style="stop-color:#1F4492;stop-opacity:1" />
                </linearGradient>
              </defs>
              <path d="M0 0h24v24H0z" fill="url(#logoGradient)"/>
              <path d="M8.917 4.818h11.334v6.919H8.917z" fill="url(#logoGradient)" opacity="0.8"/>
            </svg>
          </div>
          <h1 class="app-title">地面站多元化数据管理平台</h1>
        </div>
        
        <!-- 导航菜单 -->
        <div class="header-nav">
          <div class="nav-item" :class="{ active: selectedKeys.includes('1') }" @click="handleMenuClick({ key: '1' })">
            控制面板
          </div>
          <div class="nav-item" :class="{ active: selectedKeys.includes('2') }" @click="handleMenuClick({ key: '2' })">
            数据存储配置与备份
          </div>
          <div class="nav-item">数据检索</div>
          <div class="nav-item">性能监控</div>
          <div class="nav-item">无人机标注数据</div>
          <div class="nav-item">操作日志</div>
          <div class="nav-item">存储任务调度</div>
        </div>
      </div>
      
      <!-- 活跃导航项底部高亮条 -->
      <div class="nav-highlight" v-if="selectedKeys.includes('1')" style="left: 365px; width: 111px;"></div>
      <div class="nav-highlight" v-if="selectedKeys.includes('2')" style="left: 476px; width: 116px;"></div>
    </div>

    <!-- 主要内容区域 -->
    <div class="app-main">
      <router-view />
    </div>
  </div>
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Source Han Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #0C121C;
  color: #fff;
}

#app {
  min-height: 100vh;
}
</style>

<style scoped>
.app-container {
  min-height: 100vh;
  background: #0C121C;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  height: 48px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.logo-section {
  width: 365px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
}

.logo-section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 4px;
  background: radial-gradient(ellipse at center, #B0F4FF 0%, #B0F4FF 25%, #1F81C8 50%, rgba(31, 129, 200, 0.17) 75%, rgba(7, 77, 131, 0) 100%);
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(2px 2px 8px #2AB7FF);
}

.app-title {
  color: #EDF9FF;
  font-size: 24px;
  font-weight: bold;
  font-family: 'YouSheBiaoTiHei', 'Source Han Sans', sans-serif;
  margin: 0;
  opacity: 0.88;
  filter: drop-shadow(2px 2px 8px #2AB7FF);
}

.header-nav {
  display: flex;
  height: 48px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 30px;
  height: 44px;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  font-family: 'Source Han Sans', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.nav-item:hover {
  color: #fff;
}

.nav-item.active {
  color: #fff;
}

.nav-highlight {
  position: absolute;
  bottom: 0;
  height: 4px;
  background: radial-gradient(ellipse at center, #B0F4FF 0%, #B0F4FF 25%, #1F81C8 50%, rgba(31, 129, 200, 0.17) 75%, rgba(7, 77, 131, 0) 100%);
  transition: all 0.3s ease;
}

.app-main {
  flex: 1;
  padding: 0;
  background: #0C121C;
}

</style>
